package com.asia5b.a5mall.middleware.model.bean;

import android.text.TextUtils;
import android.webkit.JavascriptInterface;

import com.asia5b.a5mall.middleware.api.NetFectory;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * Created by zhangyuncai on 2018/11/27.
 */
public abstract class JsCall extends Object {
    public static final String H5_JSCALL_NAME = "Android";
    //给html提供的有参函数，html调用我们这个方法 ： window.Android.HtmlcallJava2("IT-homer blog");
    @JavascriptInterface
    public void HtmlcallJava2(final String param) {
        NetFectory.Companion.printJson(param);
        if (!TextUtils.isEmpty(param)) {
            Observable.just(param)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(s -> {
                        callbackParam(s);
                    });
        }
    }

    public abstract void callbackParam(String param);
}
